def str_test():
    str1 = 'hello world'
    for i in str1:
        print(i, end=' ')

    print(str1.count('l'))
    print(str1.isalnum())
    print(str1.isalpha())
    print(str1.islower())
    print(str1.isupper())
    print(str1.find('lo'))
    print(str1.replace('world', 'python'))
    str2 = '  hello world '
    print(str2.strip())
    str3 = 'how are you'
    print(str3.split())  # 默认按空格拆分
    print(str3.split(','))
    str4 = 'hello\nhowareyou\nworld'
    print(str4.splitlines())


# str_test()
def str_qiepian():
    num_str = '0123456789'
    print(num_str[2:6])
    print(num_str[2:])
    print(num_str[:6])
    print(num_str[:])
    print(num_str[::2])
    print(num_str[1::2])
    print(num_str[:-1])
    print(num_str[-2:])
    print(num_str[::-1])


str_qiepian()
